fix: support large audio files (>25 MB) for transcription#37
Merged
Conversation
Flask had no MAX_CONTENT_LENGTH set, causing Werkzeug to reject uploads over 25 MB before they reached the route handler — making the existing compression logic unreachable dead code. - Set MAX_CONTENT_LENGTH to 2 GB to accommodate long WAV recordings - Calculate compression bitrate dynamically based on audio duration so the output always fits under Whisper's 25 MB API limit, regardless of how long the recording is (previously hardcoded 64k caused failures on recordings longer than ~50 minutes) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shaulams
approved these changes
Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Uploading audio files larger than 25 MB failed with a 413 error. The app never set `MAX_CONTENT_LENGTH`, so Flask/Werkzeug silently enforced a 25 MB upload limit — making the existing compression logic unreachable dead code.
Changes
1. Set MAX_CONTENT_LENGTH to 2 GB
Covers ~120 min WAV recordings at broadcast quality (the stated use case).
2. Dynamic compression bitrate
The hardcoded `64k` bitrate caused failures on recordings longer than ~50 minutes — the compressed file still exceeded Whisper's 25 MB API limit. Bitrate is now calculated from audio duration to guarantee output stays under 24 MB, capped between 8–64 kbps. Whisper handles low bitrates well for speech.
Both interview and narration transcription paths are fixed.
Tested
Verified with a 777 MB / ~76 min WAV file that previously failed at upload and now transcribes successfully.